﻿@using ChampionsLeagueBets.Domain.Common
@using ChampionsLeagueBets.Web.Mvc.Authentication
@using ChampionsLeagueBets.Web.Mvc.Common
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head id="Head1" runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf8" />

    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
	<link href="@Url.Content("~/Content/jquery-ui-1.8.14.custom.css")" rel="stylesheet" type="text/css" />

    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script src="@Url.Content("~/Content/js/jquery-1.6.1.min.js")" type="text/javascript"></script>    
    <script src="@Url.Content("~/Content/js/modernizr-1.7.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Content/js/jquery.validate.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Content/js/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
	<script src="@Url.Content("~/Content/js/jquery-ui-1.8.14.custom.min.js")" type="text/javascript"></script>
	<script src="@Url.Content("~/Content/js/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>
	<script src="@Url.Content("~/Content/js/jquery.maskedinput-1.2.2.js")" type="text/javascript"></script>
	<script src="@Url.Content("~/Content/js/jquery.numeric.js")" type="text/javascript"></script>

    <title>@ViewBag.Title</title>

	<script language="javascript" type="text/javascript">
		jQuery(document).ready(function ($) {
			ShowPageMessage();
		});

		function ShowPageMessage() {
			$("#page-message").delay(500).show('slide', { direction: "up" }, 500, callback);

			function callback() {
				$("#page-message").delay(5000).hide('slide', { direction: "up" }, 1000);
			};
		}
		
		function SucessInvitation() {
			$("#page-message-contener").html("<div id='page-message'><div id='page-message-success'>Zaproszenie zostało wysłane.</div></div>");
			ShowPageMessage();
		}

		function ErrorInvitation() {
			$("#page-message-contener").html("<div id='page-message'><div id='page-message-error'>Wystąpił błąd podczas wysyłania zaproszenia.</div></div>");
			ShowPageMessage();
		}
	</script>

</head>

<body>
    <div class="page">

		<div id="page-message-contener">
			@if (ViewContext.TempData[ActionConfirmation.TempDataKey] != null)
			{
				var confirm = (ActionConfirmation) ViewContext.TempData[ActionConfirmation.TempDataKey];
				<div id="page-message">
					<div id="@(confirm.WasSuccessful ? "page-message-success" : "page-message-error")">@(confirm.Message)</div>
				</div>
			}
		</div>

		@if (Context.User.Identity.IsAuthenticated)
		{
			<div id="personalData">Witaj, <strong>@(Html.ActionLink<UsersController>(c => c.Edit(@RightPrincipal.CurrentUser.Id), @Context.User.Identity.Name)) </strong>&nbsp;&nbsp;&nbsp; @(Html.ActionLink<UsersController>(c => c.LogOut(), "Wyloguj"))</div>
		}

		<div id="header">
			<img style="z-index: 100" src="@Url.Content("~/Content/images/bets.png")" />
		</div>

        <div id="mainContent">
            <div class="columnsContainer">
                <div class="leftColumn">

					@if (Context.User.Identity.IsAuthenticated)
					{
						<ul>
							<li>@(Html.ActionLink<HomeController>(c => c.Index(), "Strona główna"))</li>
							@if (RightPrincipal.CurrentUser.IsAdmin)
							{
								<li>@(Html.ActionLink<HomeController>(c => c.Administration(), "Administracja"))</li>
							}
							<li>@(Html.ActionLink<TournamentsController>(c => c.UserTournaments(), "Twoje zakłady"))</li>
						</ul>

						<button id="send-invitation" style="margin-right: 30px"><img width="32" height="32" style="vertical-align: middle" src="@Url.Content("~/Content/images/invitation-64.png")"/> Wyślij zaproszenie</button>
					}
                </div>

                <div class="rightColumn">
                    <div id="page-title"><img class="page-title-image" src="@Url.Content(ViewBag.Image)" alt="logo" /><span>@ViewBag.Title</span></div>
                    @RenderBody()
                </div>

                <div class="clear">
                </div>

            </div>
        </div>

		<div id="footer">
			bet-at-work v. @VersionHelper.GetVersion(), 2011 Wszelkie prawa zastrzeżone
		</div>

    </div><!--/page-->


<div id="invitation-form" title="Zaproś znajomego">
	@using (Ajax.BeginForm("Create", "Invitations", new AjaxOptions() { OnSuccess = "SucessInvitation", OnFailure = "ErrorInvitation" }))
	{
		@Html.AntiForgeryToken()
	
		<fieldset class="form-data">
			<legend>Zaproszenie</legend>
			<table>
				<tr>
					<th>
						Email zapraszanego:
					</th>
					<td>@Html.TextBox("email")
					</td>
				</tr>
			</table>
		</fieldset>

		@Html.SubmitButton("btnInvitation", "Zapisz", new { @style = "display:none" })
	}
</div>


	<script type="text/javascript" language="javascript">
		$(document).ready(function () {
			$("input:submit, button, .link-button").button();

			$("#invitation-form").dialog({
				autoOpen: false,
				height: 200,
				width: 700,
				modal: true,
				buttons: {
					"Zaproś": function () {
						$("#btnInvitation").click();
						$(this).dialog("close");
					},
					"Anuluj": function () {
						$(this).dialog("close");
					}
				}
			});

			$("#send-invitation")
			.click(function () {
				$("#invitation-form").dialog("open");
			});
			
		});
	</script>
</body>
</html>
